import logging
from logging.handlers import RotatingFileHandler


def getLogHandler():
    # # 移除flask自带的handler
    # app.logger.removeHandler(default_handler)
    # 创建一个RotatingFileHandler 对象
    file_handler = RotatingFileHandler('MCE.log', maxBytes=16384, backupCount=10, encoding="utf-8")
    # 设置handler级别为WARNING
    file_handler.setLevel(logging.WARNING)
    # 创建日志记录格式
    file_formater = logging.Formatter('%(asctime)s %(levelname)s: %(message)s [in %(filename)s: %(lineno)d]')
    # 将日志格式对象添加到handler中
    file_handler.setFormatter(file_formater)

    return file_handler
